#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

class point_t 
{
public:
    point_t();
    point_t(int x_, int y_): x(x_), y(y_){}
    int x, y;
};

point_t findClose(const vector<point_t> &pointVec)
{
    int minDis = 100000;
    point_t ans(0,0);
    for (int i = 0; i < 15; i++) {
	for (int j = 0; j < 15; j++) {
	    int dis = 0;
	    for (int k = 0; k < pointVec.size(); k++) {
		dis += abs(pointVec[k].x - i) + abs(pointVec[k].y - j);
	    }
	    if (dis <= minDis) {
		minDis = dis;
		ans = point_t(i,j);
	    }
	    cout << i << " " << j << " " << dis << endl;
	}
    }
	
    return ans;
}

point_t findClose2(const vector<point_t> &pointVec)
{
    int minDis = 100000;
    point_t ans(0,0);
    int x = 0, y = 0;
    for (int i = 0; i < pointVec.size(); i++) {
	x += pointVec[i].x;
	y += pointVec[i].y;
    }
    ans.x = x/pointVec.size();
    ans.y = y/pointVec.size();
    cout << x << " " << y << " " << pointVec.size() << endl;
	
    return ans;
}

int main(int argc, char **argv)
{
    vector<point_t> pointVec;
    pointVec.push_back(point_t(1,1)); 
    pointVec.push_back(point_t(1,1)); 
    pointVec.push_back(point_t(1,1)); 
    pointVec.push_back(point_t(1,1)); 
    pointVec.push_back(point_t(1,1)); 
    pointVec.push_back(point_t(1,1)); 
    pointVec.push_back(point_t(4,5)); 
    pointVec.push_back(point_t(2,3)); 
    pointVec.push_back(point_t(2,3)); 
    pointVec.push_back(point_t(2,3)); 
    pointVec.push_back(point_t(6,7)); 
    pointVec.push_back(point_t(8,9)); 
    pointVec.push_back(point_t(2,4)); 
    pointVec.push_back(point_t(2,4)); 
    point_t ans = findClose(pointVec);
    point_t ans2 = findClose2(pointVec);
    cout << ans.x << " " << ans.y << endl;
    cout << ans2.x << " " << ans2.y << endl;
    return 0;
}
